<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.text.SimpleDateFormat"%>  
<%@page import="java.util.Calendar"%>   
<%@page import="java.util.Date"%>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加计划</title>
<!-- qt-learnplan-publish.jsp -->
<!-- 主题模式  -->
<link rel="stylesheet" href="public/css/journal.css" />
<link rel="stylesheet" href="public/css/text.css" />
</head>

<body class="fatherdiv">
	<div>
			<div class="nav">
					您好! 
					<a href="" class="">${userinfo.studentName}</a> 
					部门： <a>${classEntity.className}</a>
					 部门经理： <a>${monitor.studentName}</a> 
					 学分：
					<a href="javascript:loadXxx('stu/myscore.jsp')">[${userinfo.totalCredits}分]</a> 
					<a target="" class="" href="">[查看课表]</a> 
					<a id="qiantaipass" class="" href="qt-user-updatepass">[修改密码]</a> 
					<a class="" href="logout" onclick="return confirm('确定退出？')">[注销]</a>
	</div>
		<ul class="nav_head">
			<li>
				<div>
					<img src="public/images/xuexi.png" /> <a href="qiantai">快乐学习</a>
				</div>
			</li>
			<li>
				<div>
					<img src="public/images/quxian.png" /> <a href="qt-assessment">学习评估</a>
				</div>
			</li>
			<!-- <li>
				<div>
					<img src="public/images/rongyu.png" /> <a href="qt-my-honor">我的荣誉</a>
				</div>
			</li> -->
			<li>
				<div>
					<img src="public/images/jihua.png" /> <a
						href="qt-learnplan-list?id=${userinfo.stuId}">学习计划</a>
				</div>
			</li>
			<li>
				<div>
					<img src="public/images/tuadui.png" /> <a href="qt-team-list?id=${userinfo.stuId}">项目团队</a>
				</div>
			</li>
			<li>
				<div>
					<img src="public/images/jiuye.png" /> <a
						href="chaxuijingyan?id=-1">就业资讯</a>
				</div>
			</li>
		</ul>
		<!--头部上-->
	</div>
	<!--
            	作者：offline
            	时间：2017-11-14
            	描述：日志导航div
            -->
	<div class="journal_body_div">
		<div class="journal_navigation_div">
			<ul class="navigation_ul">
				<li class="navigation_li li_selected">
						<%
							SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
							Calendar cl = Calendar.getInstance(); 
							cl.setTime(new Date());
							Integer week = cl.get(Calendar.WEEK_OF_YEAR);   
							System.out.println(week);   
							cl.add(Calendar.DAY_OF_MONTH, -7);  
							Integer year = cl.get(Calendar.YEAR);  
							if(week<cl.get(Calendar.WEEK_OF_YEAR)){  
							    year+=1;  
							}  
							System.out.println(year+"年第"+week+"周");
						%>
					<a class="li_a" href="qt-learnplan-add?week=<%=week%>&stuId=${userinfo.stuId}">添加计划</a>
				</li>
				<li class="navigation_li">
					<a class="li_a" href="qt-learnplan-list?id=${userinfo.stuId}">我的学习计划列表</a>
				</li>
				<c:choose>
					<c:when test="${identity.stu_identity != '组长'}">
						<li class="navigation_li" style="display:none;">
							<a class="li_a">组员学习计划列表</a>
						</li>
					</c:when>
					<c:otherwise>
						<li class="navigation_li li_selected">
						<a class="li_a" href="qt-crew?id=${userinfo.stuId}">组员学习计划列表</a>
						</li>
					</c:otherwise>
				</c:choose>
			</ul>
		</div>
		<div class="journal_tabs">
			<div class="tabs_div">
				<div
					style="float: left; border: 1px solid dodgerblue; border-bottom: none; width: 20px; height: 0px; margin-top: 30px; margin-left: -21px;"></div>
				<div class="tabs_content">发表计划</div>
				<div
					style="border: 1px solid dodgerblue; border-bottom: none; height: 0px; margin-left: 101px;"></div>
			</div>
			<div>
				<div class="plan_table_div">
					<form action="plan-publish" method="post">
						<input name="stuId" type="hidden" value="${userinfo.stuId}"/>
						<input name="week" type="hidden" value="${week}"/>
						<table class="plan_table" id="tab">
							<tr>
								<td colspan="5"><b>${userinfo.studentName}</b>${year}年第 ${week} 周 学习计划</td>
							</tr>
							<tr>
								<td>计划内容</td>
								<td>实施时间</td>
								<td width="23%">需要的支持</td>
								<td width="14%">完成情况</td>
								<td width="10%">操作</td>
							</tr>
							<c:choose>
								<c:when test="${planEntity!=null}">
									<c:forEach items="${planEntity}" var="planlist" >
										<tr>
											<td>
												<input id="id" type="hidden" name="id" value="${planlist.learnplanId}"/>
												<textarea name="planContent" class="plan_content">${planlist.planContent}</textarea>
											</td>
											<td>
												<input name="planStartTime" class="plan_time" type="date" value="${planlist.endTime}"/>-
												<input name="planEndTime" class="plan_time" type="date" value="${planlist.planStartTime}" />
											</td>
											<td><textarea name="planSupport" class="plan_support">${planlist.needSupport}</textarea></td>
											<td><select name="planCompletion">
													<option ${planlist.completion=='未开始' ? 'selected' : ''}>未开始</option>
													<option ${planlist.completion=='进行中' ? 'selected' : ''}>进行中</option>
													<option ${planlist.completion=='已完成' ? 'selected' : ''}>已完成</option>
											</select></td>
											<td class="delete_plan_td">
												<a style="cursor:pointer;" class="rm">删除</a>
											</td>
										</tr>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<tr>
										<td>
											<input type="hidden" name="id" value="-1"/>
											<textarea name="planContent" class="plan_content"></textarea>
										</td>
										<td><input name="planStartTime" class="plan_time" type="date" />-<input name="planEndTime" class="plan_time" type="date" /></td>
										<td><textarea name="planSupport" class="plan_support"></textarea></td>
										<td><select name="planCompletion">
												<option>未开始</option>
												<option>进行中</option>
												<option>已完成</option>
										</select></td>
										<td class="delete_plan_td">
											<a class="rm">删除</a>
										</td>
									</tr>
								</c:otherwise>
							</c:choose>
							
						</table>
						<div class="plan_btn_div">
							<input class="plan_btn" type="button" value="增加一行" />
							<button class="plan_btn keep">保存</button>
						</div>
						<script src="public/js/jquery-1.8.0.js"></script>
						<script>
							$(document).ready(function() {
								//新增
								$("input[value=增加一行]").click(function() {
									var tr = $("<tr>");
									var input=$("<input>").attr("type","hidden").attr("name","id").attr("value","-1");
									var textarea1=$("<textarea>").attr("name", "planContent").attr("class","plan_content");
									var date1=$("<input>").attr("type", "date").attr("name", "planStartTime").attr("class","plan_time");
									var date2=$("<input>").attr("type", "date").attr("name", "planEndTime").attr("class","plan_time");
									var textarea2=$("<textarea>").attr("name", "planSupport").attr("class","plan_support");
									//创建下拉框
									var select = $("<select>").attr("name", "planCompletion");
									var option1 = $("<option>").attr("value", "未开始");
									option1.append("未开始");
									var option2 = $("<option>").attr("value", "进行中");
									option2.append("进行中");
									var option3 = $("<option>").attr("value", "已完成");
									option3.append("已完成");
									select.append(option1);
									select.append(option2);
									select.append(option3);
									var deletetr = $("<a>").attr("class", "rm").css("cursor","pointer");
									deletetr.append("删除");
									for(var i = 1; i <= 5; i++) {
										var td = $("<td>");
										if(i == 1){
											td.append(input);
											td.append(textarea1);
										}
										if(i == 2){
											td.append(date1);
											td.append("-");
											td.append(date2);
										}
										if(i == 3){
											td.append(textarea2);
										}
										if(i == 4) {
											td.append(select);
										} 
										if(i == 5) {
											td.append(deletetr);
										} 
										tr.append(td);
									}
									$("#tab").append(tr);
								});
							});
							$('table').on('click', '.rm', function () {
							      if (confirm("是否删除？")) {
							    	   var that = this;
							           var id = $("#id").val();
							           if (id) {
								           $.post('qt-delete', {id: id}, function () {
								            	$(that).closest('tr').remove();
								           });
							           }else{
							        	   alert("该计划不存在！");
							           }
							      } else {
							    	  $(that).closest('tr').remove();
							      }
							});
						</script>
					</form>
				</div>
			</div>
		</div>
		<!--底部下-->
		<div class="home_page_bottom">
			<div class="botton_left">
				<img style="height: 50px; margin-left: 10px;"
					src="public/images/downloadlog.png" />
			</div>
			<div class="botton_right">
				<div>
					?2017 <a style="color: gray;">中科韬睿</a> 版权所有 版本 Ver 1.1.8
				</div>
				<div>研发部技术总监 李赞红 郭华</div>
				<div>电话 18573308384 18673363711</div>
			</div>
		</div>

	</div>
</body>

</html>